$(function(){
	var time = 1000*60*60*6;
	setInterval(function(){
		location.reload(true);
	},time);
	//天气
	$.ax(
		"resource/getWeatherInform",
		null,
		null,
		"get",
		"json",
		function(data){
			
			var obj = data.results[0].weather_data;
			var str = "";
			for(var i= 0 ; i<obj.length;i++){
				//判断有带实时温度的
				var da = obj[i].date;
				if(da.indexOf("(")>0){
					da = da.substring(0,da.indexOf("("));
				}
				str = str + "<li><p>"+da+"</p><p><img src='"+obj[i].dayPictureUrl+"'/><img src='"+obj[i].nightPictureUrl+"'/></p><p>"+obj[i].weather+obj[i].temperature+"</p><p>"+obj[i].wind+"</p></li>";
				
			}
			$(".weatherBox ul").html(str);
			$(".weatherBox ul li").addClass("col-lg-3 col-md-3");
		},
		function(){
			alert("error");
		}
	);	
	var arr = new Array();//存放视频路径
	$.ax(
		"resource/getLastCarouselResources",
		null,
		null,
		"get",
		"json",
		function(data){
			if(data.messageCode===200){
				var obj = data.sysdata.resources;
				var str = "";
				
				for(var i = 0 ; i <obj.length;i++){
					if(obj[i].content!=undefined){
						str = str+ "<p>"+obj[i].content+"</p>";
					}
					var play = obj[i].video;
					var index = play.toString().lastIndexOf(".");
					var format = play.substring(index+1);
					if(format=="mp4"){
						format = "m4v";
					}
					var vObj = new Object();
					vObj[format] = play;
					arr[i] = vObj;
					
					
				}
				$("marquee").html(str);
				videofun();
			}
		},
		function(){
			alert("error");
		}
	);
	
	function videofun(){
		console.log(arr);
		var myPlaylist = new jPlayerPlaylist({
			jPlayer: "#jquery_jplayer_N",
			cssSelectorAncestor: "#jp_container_N"
		},arr, {
			playlistOptions: {
				autoPlay: true,
				enableRemoveControls: true
			},
			swfPath: "file/jquery.jplayer.swf",
			supplied: "webmv, ogv, m4v, oga, mp3,flv",
			solution: "flash,html",
			useStateClassSkin: true,
			autoBlur: false,
			smoothPlayBar: true,
			keyEnabled: true,
			audioFullScreen: true,
			size:{
				width:"100%",
//				height:"100%",
				cssClass:""
			},
			loop:true,
			repeat:function(event) {
			  if(event.jPlayer.options.loop) {
			    $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
			      $(this).jPlayer("play");
			    });
			  } else {
			    $(this).unbind(".jPlayerRepeat");
			  }
			}
		});
	}
	
})
 

